package com.taotao.fluentmybatisdocs.controller;

import com.taotao.fluentmybatisdocs.entity.YourTableEntity;
import com.taotao.fluentmybatisdocs.mapper.YourTableMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: fluent-mybatis-docs
 * @ClassName YourTableController
 * @description:
 * @author: wangjin
 * @create: 2023-07-31 09:16
 * @Version 1.0
 **/
@RestController
public class YourTableController {

    @Autowired
    private YourTableMapper yourTableMapper;

    @RequestMapping("/query")
    public List query() {

        List<YourTableEntity> list = yourTableMapper.listObjs(yourTableMapper.query());
        return list;
    }

    @RequestMapping("/insert")
    public void insert() {
        List<YourTableEntity> entities = new ArrayList<>();
        entities.add(new YourTableEntity().setName("Fluent Mybatis").setEmail("darui.wu@163.com"));
        entities.add(new YourTableEntity().setName("Fluent Mybatis Demo").setEmail("darui.wu@163.com"));
        entities.add(new YourTableEntity().setName("Test4J").setEmail("darui.wu@163.com"));
        int count = yourTableMapper.insertBatch(entities);
        System.out.println("count:" + count);
        System.out.println("entity:" + entities);

        
    }

}
